package com.haoshuang.zhouzhoubang.ui.activity

import android.Manifest
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.Settings
import cn.jzvd.Jzvd
import com.bumptech.glide.Glide
import com.haoshuang.zhouzhoubang.databinding.ActivityVideoBinding
import com.haoshuang.zhouzhoubang.ui.dialog.Tis2Dialog
import com.haoshuang.zhouzhoubang.utils.DownloadSaveImg
import com.haoshuang.zhouzhoubang.utils.PermissionHelper
import com.lxj.xpopup.XPopup
import com.mufeng.libs.base.BaseVMActivity
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.utils.ktx.runOnUIThread
import com.mufeng.libs.utils.view.clickWithTrigger
import com.mufeng.libs.utils.view.gone
import com.mufeng.libs.utils.view.visible


/**
 *
 */
class VideoActivity : BaseVMActivity<BaseViewModel, ActivityVideoBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
        binding.appBar.ivBack.clickWithTrigger { finish() }
        binding.appBar.tvTitle.text = "视频"
    }

    override fun initData() {
        var url = intent.getStringExtra("url")
        binding.appBar.tvRight.gone()

        binding.myJzvdStd.setUp(
            url,
            ""
        )
        binding.myJzvdStd.startVideo()
        if (url!!.contains("http")) {
            Glide.with(this)
                .load(url + "?x-oss-process=video/snapshot,t_1000,m_fast")
                .into(binding.myJzvdStd.thumbImageView)
        }

    }

    override fun startObserve() {
    }

    override fun onPause() {
        super.onPause()
        Jzvd.releaseAllVideos()
    }

    override fun onBackPressed() {
        if (Jzvd.backPress()) {
            return
        }
        super.onBackPressed()
    }

}